<fieldset>
	<div class="deliveries view">
		<h2><?php  echo __('Receive Orders'); ?></h2>
		<br />

		<table class="inlineTable">    
		    <tr>
				<td class="heading"><?php echo __('Date Received'); ?></td>
				<td class="data"><?php echo h($delivery['Delivery']['created']); ?></td>
			</tr>
		                
			<tr>
		        <td class="heading"><?php echo __('Order Id'); ?></td>
				<td class="data"><?php echo $this->Html->link($delivery['Orders']['id'], array('controller' => 'orders', 'action' => 'view', $delivery['Orders']['id'])); ?></td>
		    </tr>
		</table>

		<br /><br/>
		<div class="newbutton">
		<ul>
			<li><?php echo $this->Html->link(__('Back'), array('action' => 'index')); ?></li>
			<li><?php echo $this->Form->postLink(__('Archive'), array('action' => 'delete', $delivery['Delivery']['id']), null, __('Are you sure you want to archive this?')); ?></li>
			<li><?php echo $this->Html->link(__('Add Gift'), array('controller' => 'gifts','action' => 'addgift', $delivery['Delivery']['id'])); ?></li>
		</ul>
		</div>
		<br /><br /><br />


		<!doctype html>

	<script src ="app/webroot/js/bootstrap/bootstrap.js"></script>
	<script>
		$('#myTab a').click(function (e) {
			e.preventDefault()
			$(this).tab('show')

		})
	</script>

	<ul class="nav nav-tabs" id="myTab">
		<li class="active"><a href="#tab-1" data-toggle="tab">Products Delivered</a></li>
		<li><a href="#tab-2" data-toggle="tab">Gifts</a></li>
	</ul>


	<div class="tab-content">
		<div class="tab-pane active" id="tab-1">
			<?php if (!empty($delivery['Ordersproducts'])){?> 
			<table class="table" cellpadding="0" cellspacing="0">
				<tr>
						<th>Brand</th>
						<th>Range</th>
						<th>Category</th>
						<th>Description</th>
						<th>Delivered Quantity</th>
						<th>Actions</th>
				</tr>
				<?php foreach ($delivery['Ordersproducts'] as $product): ?>
				<tr>
					<td>
						<?php echo $this->Html->link($product['Brand']['name'], array('controller' => 'productsbrands', 'action' => 'view', $product['Products']['productsbrands_id'])); ?>
					</td>
					<td>
						<?php echo $this->Html->link($product['Range']['name'], array('controller' => 'productsranges', 'action' => 'view', $product['Products']['productsranges_id'])); ?>
					</td>
					<td>
						<?php echo $this->Html->link($product['Category']['name'], array('controller' => 'productscategories', 'action' => 'view', $product['Products']['productscategories_id'])); ?>
					</td>
					<td>
						<?php echo $this->Html->link($product['Products']['description'], array('controller' => 'products', 'action' => 'view', $product['Products']['id'])); ?>
					</td>
					<td><?php echo h($product['deliveredQty']); ?>&nbsp;</td>
					<td>
						<?php echo $this->Html->link(__('Edit Quantity'), array('action' => 'editqty', $product['id'])); ?>&nbsp;&nbsp;
					</td>
				</tr>
				
				<?php endforeach; ?>
			</table> 
		<?php } else { echo 'No products was delivered in this delivery.'; } ?> 
	</div> 


	<div class="tab-pane" id="tab-2">
		<?php if (!empty($delivery['Gift'])){?> 
		<table class="table" cellpadding="0" cellspacing="0">
				<tr>
						<th>Brand</th>
						<th>Range</th>
						<th>Category</th>
						<th>Description</th>
						<th>Delivered Quantity</th>
				</tr>
				<?php foreach ($delivery['Gift'] as $product): ?>
				<tr>
					<td>
						<?php echo $this->Html->link($product['Brand']['name'], array('controller' => 'productsbrands', 'action' => 'view', $product['Products']['productsbrands_id'])); ?>
					</td>
					<td>
						<?php echo $this->Html->link($product['Range']['name'], array('controller' => 'productsranges', 'action' => 'view', $product['Products']['productsranges_id'])); ?>
					</td>
					<td>
						<?php echo $this->Html->link($product['Category']['name'], array('controller' => 'productscategories', 'action' => 'view', $product['Products']['productscategories_id'])); ?>
					</td>
					<td>
						<?php echo $this->Html->link($product['Products']['description'], array('controller' => 'products', 'action' => 'view', $product['Products']['id'])); ?>
					</td>
					<td><?php echo h($product['deliveredQty']); ?>&nbsp;</td>
				</tr>
				
				<?php endforeach; ?>
			</table> 
	<?php } else{ echo 'No gift was delivered in this delivery.';} ?> 
	</div>


	</div>
</fieldset>